/*
 *  txdnet.cn tonydon
 * 
 */
package cn.txdnet.txcms.service;

import cn.txdnet.txcms.dao.TinyCmtDAO;
import cn.txdnet.txcms.domain.TinyCmt;
import cn.txdnet.txcms.dto.PageDTO;
import cn.txdnet.txcms.query.TinyCmtQuery;
import cn.txdnet.txweb.basedao.FacadeProxy;
import cn.txdnet.txweb.utils.StringUtil;
import java.util.HashMap;
import java.util.Map;
import txdnet.util.StaticMark;

/**
 *
 * @author tangxiaodong
 */
public class TinyCmtService {

    /**
     * 保存微评信息
     *
     * @param tc
     * @return
     */
    public static boolean make(TinyCmt tc) {
        TinyCmtDAO dao = FacadeProxy.getManualCommitProxy(TinyCmtDAO.class);
        return (dao.insertTinyCmt(tc) > 0 ? true : false);
    }

    /**
     * 批量删除评论
     *
     * @param ids
     * @return
     */
    public static int deleteBatch(String ids) {
        TinyCmtDAO dao = FacadeProxy.getManualCommitProxy(TinyCmtDAO.class);
        return dao.deleteTinyCmt(StringUtil.parseStrToLongArray(ids, StaticMark.STR_LINE));
    }

    /**
     * 批量更新状态
     * @param ids
     * @param pubstate
     * @return 
     */
    public static int updatePubstateBatch(String ids, byte pubstate) {
        Map<String, Object> m = new HashMap<String, Object>(2);
        m.put("ida", StringUtil.parseStrToLongArray(ids, StaticMark.STR_LINE));
        m.put("pubstate", pubstate);
        TinyCmtDAO dao = FacadeProxy.getManualCommitProxy(TinyCmtDAO.class);
        return dao.updatePubstate(m);
    }
    
    /**
     * 查询评论
     * @param query
     * @return 
     */
    public static PageDTO queryByFactor(TinyCmtQuery query){
        return  FacadeProxy.getAutoCommitProxy(TinyCmtDAO.class).queryByFactor(query);
    }
}
